<?php
/**
 * Created by PhpStorm.
 * User: yuyiwen
 * Date: 2018/10/24
 * Time: 上午10:52
 */

namespace app\index\controller;


use think\Controller;

class User extends  Controller
{
    public function user ()
    {
        return view();
    }
    public function myuser ()
    {
        return view();
    }
    public function partners ()
    {
        $member = model('member');
        // SELECT a.*,b.nickname as pnickname FROM yysh_member as a LEFT JOIN yysh_member as b ON a.pid = b.id WHERE a.id = 10
        $partners = $member->getAllPartners(session('id'));

        $this->assign('partners' , $partners);

        return view();
    }
    public function myqrcode ()
    {
        $id = session('id');
        $key = '3edtrjhkop90878yghvnmkljjhgcfyuy';
        $key = md5($id . $key);
        $text = url('index/log/login' , '' , true , true) . '?id='.$id . '&key='.$key;

        $this->assign('text' , $text);
        return view();
    }

    public function qrcode ()
    {
        header('Content-type:image/png');
        // 导入二维码插件
        vendor('phpqrcode.phpqrcode');
        $qrcode = new \QRcode();
        $id = session('id');

        $key = '3edtrjhkop90878yghvnmkljjhgcfyuy';
        $key = md5($id . $key);
        $text = url('index/log/login' , '' , true , true) . '?id='.$id . '&key='.$key;
        $qrcode->png($text , false , 'L' , 5 , 2 );
        die;
    }
}